/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SPasswordInfoConverter.java
 * Created：		2016年7月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.statement.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.statement.AStatement;
import com.thor.palmmall.spi.statement.SStatement;

/**
 * @author wolv
 *
 */
public class AStatementConverter implements Converter<SStatement, AStatement> {

	public static AStatementConverter getInstance() {
		if (instance == null)
			instance = new AStatementConverter();
		return instance;
	}

	private static AStatementConverter instance;

	private AStatementConverter() {
	}

	@Override
	public AStatement convert(SStatement source) {
		if (source == null)
			return null;

		AStatement target = new AStatement();
		target.setContract(UCN.newInstance(source.getContract()));
		target.setPayedTotal(source.getPayedTotal());
		target.setPayTotal(source.getPayTotal());
		target.setStore(UCN.newInstance(source.getStore()));
		target.setSubjects(ConverterUtil.convert(source.getSubjects(), ASubjectDetailConverter.getInstance()));
		target.setTenant(UCN.newInstance(source.getTenant()));
		target.setUnpayedTotal(source.getUnpayedTotal());

		return target;
	}

}
